<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>title</title>
</head>

<body>
    <p>此实例使用addEventListener()方法将click事件附加到文档.</p>
    <p>单击网页中的任意位置改变背景色:</p>
    <script>
        document.addEventListener("click", myFunc);

        function myFunc() {
            document.body.style.backgroundColor = "coral";
        }
    </script>
</body>

</html>